﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using QLTT.Models;
using QLTT.Commands;
using System.Windows.Input;
using System.Text.RegularExpressions;
using QLTT.Properties;
using MediatorLib;
using System.Windows;

namespace QLTT.ViewModels
{
    public enum PayChoice
    {
        PayMoney,
        RepaytoStudent
    };
    class StudentClassFeeViewModel : WorkspaceViewModel, System.ComponentModel.IDataErrorInfo
    {
        private Student _student;
        private icanDataContext _dataContext;
        private DelegateCommand _saveCommand;
        private DelegateCommand _registerClassCommand;
        private DelegateCommand _repayCommand;
        private DelegateCommand _cancelCommand;
        private DelegateCommand _chooseClassCommand;
        Regex rxValidate;                
        private bool _isAddFee = true;
        private bool _isRepayFee;
        private long _rLevel;
        private long _rClass;
        private long _rRegisteredClass;
        private long _rRepayClass;
        private double _payAmount = 0;
        private double _classFee = 0;
        private double _classFeeRepay = 0;
        private double _repayFee = 0;
        private double _classMonthFee = 0;
        private byte _month;
        private byte bNumberOfMonthMustPay=3;
        //Lop da dong tien hay chua dong tien lan nao
        private bool _isFirstPayFee = true;
        private string _reason;
        private string _repayReason;
        //Dung de an hien control ben khung tra no*.
        private System.Windows.Visibility _repayVisibility;
        //Dung de an hien control ben khung thu tien
        private System.Windows.Visibility _payVisibility;

        private PayChoice _choiceMode;
        public StudentClassFeeViewModel(icanDataContext dataContext)
        {
            _dataContext = dataContext;
            _student = new Student();
        }
        public StudentClassFeeViewModel(icanDataContext dataContext, Student student)
        {
            _student = student;
            _dataContext = dataContext;
            base.DisplayName = student.Name +" - "+ QLTT.Properties.Resources.Base_DisplayName_StudentClassFee;
            this.RepayVisibility = Visibility.Hidden;
            this.PayVisibility = Visibility.Visible;
        }
        public bool IsFirstPayFee
        {
            get { return _isFirstPayFee; }
            set
            {
                if (_isFirstPayFee == value) return;
                _isFirstPayFee = value;
                base.OnPropertyChanged("IsFirstPayFee");
            }
        }
        public long RLevel
        {
            get { return _rLevel; }
            set
            {
                if (_rLevel == value) return;
                _rLevel = value;
                base.OnPropertyChanged("Classes");
                base.OnPropertyChanged("RLevel");
            }
        }
        public long RClass
        {
            get { return _rClass; }
            set
            {
                if (_rClass == value) return;
                _rClass = value;
                base.OnPropertyChanged("RClass");
            }
        }
        
        public ICommand SaveCommand
        {
            get
            {
                if (_saveCommand == null)
                {
                    _saveCommand = new DelegateCommand(Save,CanSave);
                }
                return _saveCommand;
            }
        }
        public ICommand RepayCommand
        {
            get
            {
                if (_repayCommand == null)
                {
                    _repayCommand = new DelegateCommand(Repay, CanRepay);
                }
                return _repayCommand;
            }
        }
        public ICommand CancelCommand
        {
            get
            {
                if (_cancelCommand == null)
                {
                    _cancelCommand = new DelegateCommand(Cancel);
                }
                return _cancelCommand;
            }
        }
        public ICommand ChooseClassCommand
        {
            get
            {
                if (_chooseClassCommand == null)
                    _chooseClassCommand = new DelegateCommand(ChooseClass);
                return _chooseClassCommand;
            }
        }
        public ICommand RegisterClassCommand
        {
            get
            {
                if (_registerClassCommand == null)
                    _registerClassCommand = new DelegateCommand(RegisterClass, CanRegisterClass);
                return _registerClassCommand;
            }
        }
        private void ChooseClass()
        {
            ClassScheduleViewModel ws = new ClassScheduleViewModel(_dataContext, true);
            Mediator.NotifyColleagues<ClassScheduleViewModel>(Messages.WorkspaceAdd, ws);
        }
        private void RegisterClass()
        {
            try
            {
                StudentClass sClass = new StudentClass();
                Class cls = _dataContext.Classes.Where(cls1 => cls1.ID == this.RClass).Select(cls2 => cls2).FirstOrDefault();
                
                sClass.Student = _student.ID;
                sClass.Class = cls.ID;
                sClass.Class1 = cls;
                sClass.LastUpdated = DateTime.Now;
                sClass.Status = 0;
                sClass.Fee = cls.Fee;

                _dataContext.StudentClasses.InsertOnSubmit(sClass);
                _dataContext.SubmitChanges();
                
                this.RLevel = 0;
                this.RClass = 0;
                this.OnPropertyChanged("AllRegisteredClass");
                this.OnPropertyChanged("RegisteredClasses");
                base.OnPropertyChanged("Classes");
                //Update info at pay class fee panel
                this.RRegisteredClass = sClass.Class;
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("Application", ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
            }
        }
        private bool CanRegisterClass()
        {
            return this.RClass > 0;
        }
        private bool CanSave()
        {
            return this.PayAmount > 0;
        }
        private void Cancel()
        {
            Mediator.NotifyColleagues<WorkspaceViewModel>(Messages.WorkspaceRemove, this);
            WorkspaceViewModel ws = this.ParentWorkspace;
            if (ws.GetType() == typeof(StudentViewModel))
                Mediator.NotifyColleagues<WorkspaceViewModel>(Messages.WorkspaceRemove, ws);
        }
        public System.Windows.Visibility RepayVisibility
        {
            get { return _repayVisibility; }
            set {
                if (_repayVisibility == value) return;
                _repayVisibility = value;
                base.OnPropertyChanged("RepayVisibility");
            }
        }
        public System.Windows.Visibility PayVisibility
        {
            get { return _payVisibility; }
            set
            {
                if (_payVisibility == value) return;
                _payVisibility = value;
                base.OnPropertyChanged("PayVisibility");
            }
        }
        public long ID
        {
            get { return _student.ID; }
        }
        #region Information of Student
        public string Name
        {
            get { return _student.Name; }
            set
            {
                if (_student.Name == value) return;
                _student.Name = value;
                base.OnPropertyChanged("Name");
            }
        }
        public string Address
        {
            get { return _student.Address; }
            set
            {
                if (_student.Address == value) return;
                _student.Address = value;
                base.OnPropertyChanged("Address");
            }
        }
        public System.Nullable<DateTime> DateOfBirth
        {
            get { return _student.DateOfBirth; }
            set
            {
                if (_student.DateOfBirth == value) return;
                _student.DateOfBirth = value;
                base.OnPropertyChanged("DateOfBirth");
            }
        }
        public string Job
        {
            get { return _student.Job; }
            set
            {
                if (_student.Job == value) return;
                _student.Job = value;
                base.OnPropertyChanged("Job");
            }
        }
        public string Email
        {
            get { return _student.Email; }
            set
            {
                if (_student.Email == value) return;
                _student.Email = value;
                base.OnPropertyChanged("Email");
            }
        }
        public string ContactInfo
        {
            get { return _student.ContactInfo; }
            set
            {
                if (_student.ContactInfo == value) return;
                _student.ContactInfo = value;
                base.OnPropertyChanged("ContactInfo");
            }
        }
        public Double AccBalance
        {
            get { return _student.AccBalance; }
            set
            {
                if (_student.AccBalance == value) return;
                _student.AccBalance = value;
                base.OnPropertyChanged("AccBalance");
            }
        }
        public DateTime LastUpdated
        {
            get { return _student.LastUpdated.Value; }
            set
            {
                if (_student.LastUpdated.Value == value) return;
                _student.LastUpdated = value;
                base.OnPropertyChanged("LastUpdated");
            }
        }
        #endregion
        #region Information to manage Student Class
        //Fill data to student registerdClass gridview
        public ObservableCollection<StudentClassViewModel> AllRegisteredClass
        {
            get
            {
                List<long> lstClassID = _dataContext.StudentClasses.Where(sc => sc.Student == this.ID).Select(sc => sc.Class).ToList();
                List<StudentClassViewModel> lstSCVM = _dataContext.StudentClasses.Where(sc => sc.Student == this.ID).Select(c => new StudentClassViewModel(_dataContext, c)).ToList();
                return new ObservableCollection<StudentClassViewModel>(lstSCVM);
            }
        }
        /* List Level for Level Combobox*/
        public ObservableCollection<LevelViewModel> Levels
        {
            get
            {
                List<LevelViewModel> lstLevel = _dataContext.Levels.Select(lv => new LevelViewModel(_dataContext, lv)).ToList();
                LevelViewModel lvm = new LevelViewModel(_dataContext);
                lvm.Name = Resources.Combo_AllClass_Level_Default;
                lstLevel.Insert(0, lvm);
                return new ObservableCollection<LevelViewModel>(lstLevel);
            }
        }
        /* List Class for Class Combobox*/
        public ObservableCollection<ClassViewModel> Classes
        {
            get
            {
                var queryStudentClass = _dataContext.StudentClasses.Where(studentClass => studentClass.Student == _student.ID);
                List<StudentClass> lstSClass = queryStudentClass.Select(oStudentClass=>oStudentClass).ToList();
                //List class has full student
                List<long> lstFullClassId = new List<long>();
                //List registered class
                List<long> lstRegisteredClassId = new List<long>();
                List<Class> lstClassPresent = _dataContext.Classes.Where(c => c.EndDate > DateTime.Today).Select(o=>o).ToList();
                foreach (Class oClass in lstClassPresent)
                {
                    if (oClass.MaxStudent <= CountStudentInClass(oClass.ID))
                        lstFullClassId.Add(oClass.ID);
                }
                foreach (StudentClass oStudentClass in lstSClass)
                {
                    lstRegisteredClassId.Add(oStudentClass.Class);
                }
                var query = _dataContext.Classes.Where(oClass => !lstRegisteredClassId.Contains(oClass.ID));
                query = query.Where(c => c.EndDate > DateTime.Today);
                query = query.Where(c => !lstFullClassId.Contains(c.ID));
                if (this.RLevel > 0)
                    query = query.Where(c => c.Level == this.RLevel);
                List<ClassViewModel> lstClass = query.Select(cls => new ClassViewModel(_dataContext, cls)).ToList();
                return new ObservableCollection<ClassViewModel>(lstClass);
            }
        }
        private short CountStudentInClass(long clsId)
        {
            List<long> lstStudentClassId = _dataContext.StudentClasses.Where(o => o.Class == clsId).Select(o => o.ID).ToList();
            return short.Parse(lstStudentClassId.Count.ToString());
        }
        private void UpdateStudentClass()
        {

        }
        #endregion
        #region Manage FeePayment of Student
        //Fill data to student Fee Payment gridview
        public ObservableCollection<FeePaymentViewModel> AllStudentFeePayments
        {
            get
            {
                List<FeePaymentViewModel> lstFeePayment = _dataContext.FeePayments.Where(fee => fee.Student == _student.ID).Select(fee => new FeePaymentViewModel(_dataContext, fee)).ToList();
                return new ObservableCollection<FeePaymentViewModel>(lstFeePayment);
            }
        }
        public PayChoice ChoiceMode
        {
            get { return _choiceMode; }
            set
            {
                if (_choiceMode == value)
                    return;
                _choiceMode = value;
                if (_choiceMode == PayChoice.PayMoney)
                {
                    _repayVisibility = Visibility.Hidden;
                    _payVisibility = Visibility.Visible;
                }
                else
                {
                    _repayVisibility = Visibility.Visible;
                    _payVisibility = Visibility.Hidden;
                }
                    base.OnPropertyChanged("ChoiceMode");
                    base.OnPropertyChanged("RepayVisibility");
                    base.OnPropertyChanged("PayVisibility");
            }
        }
        public bool IsAddFee
        {
            get
            {
                return _isAddFee;
            }
            set
            {
                if (value == _isAddFee) return;
                _isAddFee = value;
                base.OnPropertyChanged("IsAddFee");
            }
        }
        public bool IsRepayFee
        {
            get
            {
                return _isRepayFee;
            }
            set
            {
                if (value == _isRepayFee) return;
                _isRepayFee = value;
                base.OnPropertyChanged("IsRepayFee");
            }
        }
        public ObservableCollection<ClassViewModel> RegisteredClasses
        {
            get
            {
                var queryStudentClass = _dataContext.StudentClasses.Where(studentClass => studentClass.Student == _student.ID);
                List<long> lstClassIDs = new List<long>();
                foreach (StudentClassViewModel scv in this.AllRegisteredClass)
                {
                    if (!scv.Status)
                        if (!IsPayAllFee(scv.Class, scv.Student, scv.Fee))
                            lstClassIDs.Add(scv.Class);
                }
                List<ClassViewModel> lstCVMs = _dataContext.Classes.Where(c => lstClassIDs.Contains(c.ID) && c.EndDate > DateTime.Today).Select(c => new ClassViewModel(_dataContext, c)).ToList();
                return new ObservableCollection<ClassViewModel>(lstCVMs);
            }
        }
        public long RRegisteredClass
        {
            get { return _rRegisteredClass; }
            set
            {
                if (_rRegisteredClass == value) return;
                _rRegisteredClass = value;
                base.OnPropertyChanged("RRegisteredClass");
                SetClassFee();
                //base.OnPropertyChanged("ClassFee");
            }
        }
        public double ClassFee
        {
            get
            {
                return _classFee;
            }
            set
            {
                if (_classFee == value) return;
                _classFee = value;
                base.OnPropertyChanged("ClassFee");
                SetClassMonthFee();
                base.OnPropertyChanged("ClassMonthFee");
                //Notify PayAmount(Thanh tien) change
                this.Month = _month;
            }
        }
        public double ClassMonthFee
        {
            get
            {
                return _classMonthFee;
            }
            set
            {
                if (_classMonthFee == value) return;
                _classMonthFee = value;
                base.OnPropertyChanged("ClassMonthFee");
            }
        }
        public byte Month
        {
            get
            {
                return _month;
            }
            set
            {
                if (value > bNumberOfMonthMustPay) return; 
                _month = value;
                base.OnPropertyChanged("Month");
                this.PayAmount = _month * this.ClassMonthFee;
            }
        }
        public byte[] Months
        {
            get
            {
                return new byte[]{0,1,2,3};
            }
        }
        public double PayAmount
        {
            get
            {
                return _payAmount;
            }
            set
            {
                if (_payAmount == value) return;
                _payAmount = value;
                base.OnPropertyChanged("PayAmount");

            }
        }
        
        public string Reason
        {
            get
            {
                return _reason;
            }
            set
            {
                if (_reason == value) return;
                _reason = value;
                base.OnPropertyChanged("Reason");
            }
        }
        //Đóng trả học phí
        private void Save()
        {
            try
            {
                FeePayment oFeePayment = new FeePayment();
                oFeePayment.Date = DateTime.Now;
                StringBuilder sReason = new StringBuilder();
                StudentInvokeModelView wsInvoke;
                var query = _dataContext.Classes.Where(cls1 => cls1.ID == this.RRegisteredClass);
                Class cls = query.Select(cls2 => cls2).FirstOrDefault();
                if (this.ChoiceMode == PayChoice.PayMoney)
                {
                    //Update class fee for this student
                    if (this.IsFirstPayFee)
                    {
                        StudentClass oStudentClass = _dataContext.StudentClasses.Where(o => o.Class == this.RRegisteredClass).Where(o => o.Student == _student.ID).Select(o => o).FirstOrDefault();
                        oStudentClass.Fee = this.ClassFee;
                    }
                    oFeePayment.Amount = this.PayAmount;
                    sReason.AppendFormat("{0}{1}{2}", Resources.Message_Reason_FeePaymentForClass, " ", cls.Name);
                    oFeePayment.Reason =sReason+ "\n"+ this.Reason;
                    oFeePayment.Student1 = _student;
                    oFeePayment.Class = this.RRegisteredClass;
                    oFeePayment.Months = this.Month;
                    oFeePayment.User = ViewModelBase.CurrentUser.ID;
                    _dataContext.FeePayments.InsertOnSubmit(oFeePayment);
                    _dataContext.SubmitChanges();
                    //SetClassFee();
                    this.RRegisteredClass = 0;
                    this.Month = 0;
                    this.Reason = string.Empty;
                    wsInvoke = new StudentInvokeModelView(_dataContext, _student, cls, oFeePayment,true);
                    Mediator.NotifyColleagues<StudentInvokeModelView>(Messages.WorkspaceAdd, wsInvoke);
                }
                this.OnPropertyChanged("AllStudentFeePayments");
            }
            catch (Exception ex)
            { }
        }
        #endregion
        [MediatorLib.MediatorMessageSink(Messages.UpdateChoosingClass, ParameterType = typeof(ClassViewModel))]
        public void UpdateClass(ClassViewModel oClass)
        {
            this.RLevel = oClass.Level;
            this.RClass = oClass.ID;
            this.PayAmount = oClass.Fee;
            base.OnPropertyChanged("RLevel");
            base.OnPropertyChanged("RClass");
        }
        private void SetClassFee()
        {
            if (this.RRegisteredClass > 0)
            {
                Class cls = _dataContext.Classes.Where(c => c.ID == this.RRegisteredClass).Select(c => c).FirstOrDefault();
                var q = _dataContext.StudentClasses.Where(sCls => sCls.Student == _student.ID);
                StudentClass oStudentClass = q.Where(sCls => sCls.Class == cls.ID).Select(o => o).FirstOrDefault();
                if (oStudentClass != null)
                {
                    List<FeePayment> oFeePayments = _dataContext.FeePayments.Where(o => o.Class == oStudentClass.Class).Where(o => o.Student == oStudentClass.Student).Select(o => o).ToList();
                    TimeSpan ts = cls.EndDate - cls.StartDate;
                    double dMonths = (ts.Days * 1.0 / 30);
                    double dNumMonths = Math.Round(dMonths, 0);
                    if (dNumMonths <= 0)
                        dNumMonths = 1;
                    //Lop dang ky chua dong tien lan nao
                    if (oFeePayments.Count==0)
                    {
                        this.ClassFee = cls.Fee;
                        bNumberOfMonthMustPay = (byte)dNumMonths;
                        this.Month = bNumberOfMonthMustPay;
                        this.IsFirstPayFee = true;
                    }
                    //Lop dang ky da dong tien, nhung chua do'ng du
                    else
                    {
                        this.ClassFee = oStudentClass.Fee;
                        double dMonthFee = this.ClassFee / bNumberOfMonthMustPay;
                        double dFeeHasPayed = 0;
                        foreach (FeePayment oFeePayment in oFeePayments)
                            dFeeHasPayed = dFeeHasPayed + oFeePayment.Amount;
                        bNumberOfMonthMustPay = (byte)Math.Round((((this.ClassFee - dFeeHasPayed) * 3) / this.ClassFee),0);
                        this.Month = bNumberOfMonthMustPay;
                        this.IsFirstPayFee = false;
                    }
                }
            }
        }
        private void SetClassMonthFee()
        {
            if (this.RRegisteredClass > 0 && bNumberOfMonthMustPay >=0)
            {
                Class cls = _dataContext.Classes.Where(c => c.ID == this.RRegisteredClass).Select(c => c).FirstOrDefault();
                TimeSpan ts = cls.EndDate - cls.StartDate;
                double dMonths = (ts.Days * 1.0 / 30);
                double dNumMonths = Math.Round(dMonths, 0);
                if (dNumMonths <= 0)
                    dNumMonths = 1;
                double dMonthFee = this.ClassFee / dNumMonths;
                this.ClassMonthFee = dMonthFee;
            }
        }
        private bool IsPayAllFee(long lClassId, long lStudentId, double dMustPay)
        {
            var query = _dataContext.FeePayments.Where(oFeePayment => oFeePayment.Class == lClassId);
            query = query.Where(oFeePayMent => oFeePayMent.Student == lStudentId);
            List<FeePayment> oFeePayments = query.Select(o => o).ToList();
            double dTotalPay = 0;
            foreach (FeePayment oFeePayment in oFeePayments)
                dTotalPay += oFeePayment.Amount;
            return (dMustPay > dTotalPay ? false : true);
        }
        /// <summary>
        /// Use for repay pannel
        /// </summary>
        public ObservableCollection<ClassViewModel> RepayClasses
        {
            get
            {
                var queryStudentClass = _dataContext.StudentClasses.Where(studentClass => studentClass.Student == _student.ID);
                List<long> lstClassIDs = new List<long>();
                foreach (StudentClassViewModel scv in this.AllRegisteredClass)
                {
                    if (IsPayedFee(scv.Class, scv.Student, scv.Fee) && IsStillLearn(scv.Class))
                        lstClassIDs.Add(scv.Class);
                }
                List<ClassViewModel> lstCVMs = _dataContext.Classes.Where(c => lstClassIDs.Contains(c.ID) && c.EndDate > DateTime.Today).Select(c => new ClassViewModel(_dataContext, c)).ToList();
                return new ObservableCollection<ClassViewModel>(lstCVMs);
            }
        }
        private bool IsStillLearn(long lClassId)
        {
            Class oClass = _dataContext.Classes.Where(o => o.ID == lClassId).Select(o => o).FirstOrDefault();
            return oClass.EndDate <= DateTime.Now ? false : true;
        }
        private bool IsPayedFee(long lClassId, long lStudentId, double dMustPay)
        {
            var query = _dataContext.FeePayments.Where(oFeePayment => oFeePayment.Class == lClassId);
            query = query.Where(oFeePayMent => oFeePayMent.Student == lStudentId);
            List<FeePayment> oFeePayments = query.Select(o => o).ToList();
            return (oFeePayments.Count>0 ? true : false);
        }
        public long RRepayClass
        {
            get { return _rRepayClass; }
            set
            {
                if (_rRepayClass == value) return;
                _rRepayClass = value;
                SetRepayFee();
                base.OnPropertyChanged("RRepayClass");
            }
        }
        public double ClassFeeRepay
        {
            get
            {
                return _classFeeRepay;
            }
            set
            {
                if (_classFeeRepay == value) return;
                _classFeeRepay = value;
                base.OnPropertyChanged("ClassFeeRepay");
            }
        }
        public double RepayFee
        {
            get {return _repayFee;}
            set {
                if (_repayFee == value) return;
                if (_repayFee >= this.ClassFeeRepay) _repayFee = this.ClassFeeRepay;
                else 
                    _repayFee = value;
                base.OnPropertyChanged("RepayFee");
            }
        }
        public string RepayReason
        {
            get
            {
                return _repayReason;
            }
            set
            {
                if (_repayReason == value) return;
                _repayReason = value;
                base.OnPropertyChanged("RepayReason");
            }
        }
        private bool CanRepay()
        {
            return this.RepayFee > 0;
        }
        private void SetRepayFee()
        {
            if (this.RRepayClass > 0)
            {
                double dFeeHasPayed = 0;
                List<FeePayment> oFeePayments = _dataContext.FeePayments.Where(o => o.Class == this.RRepayClass).Where(o => o.Student == _student.ID).Select(o => o).ToList();
                    foreach (FeePayment oFeePayment in oFeePayments)
                            dFeeHasPayed = dFeeHasPayed + oFeePayment.Amount;
                this.ClassFeeRepay = dFeeHasPayed;
                this.RepayFee = dFeeHasPayed;
            }
        }
        private void Repay()
        {
            try
            {
                FeePayment oFeePayment = new FeePayment();
                oFeePayment.Date = DateTime.Now;
                StringBuilder sReason = new StringBuilder();
                StudentInvokeModelView wsInvoke;
                var query = _dataContext.Classes.Where(cls1 => cls1.ID == this.RRepayClass);
                Class cls = query.Select(cls2 => cls2).FirstOrDefault();
                StudentClass oStudentClass = _dataContext.StudentClasses.Where(o => o.Class == this.RRepayClass).Where(o => o.Student == _student.ID).Select(o => o).FirstOrDefault();
                oStudentClass.Status = 1;
                oFeePayment.Amount = 0 - this.RepayFee;
                oFeePayment.Reason = this.RepayReason;
                oFeePayment.Student1 = _student;
                oFeePayment.Class = this.RRepayClass;
                oFeePayment.Months = 0;
                oFeePayment.User = ViewModelBase.CurrentUser.ID;
                _dataContext.FeePayments.InsertOnSubmit(oFeePayment);
                _dataContext.SubmitChanges();

                this.RRepayClass = 0;
                this.RepayFee = 0;
                this.ClassFeeRepay = 0;
                this.Reason = string.Empty;
                wsInvoke = new StudentInvokeModelView(_dataContext, _student, cls, oFeePayment, true);
                Mediator.NotifyColleagues<StudentInvokeModelView>(Messages.WorkspaceAdd, wsInvoke);
            }
            catch (Exception ex)
            { }
        }
        #region IDataErrorInfo Members

        public string Error
        {
            get { return null; }
        }

        public string this[string property]
        {
            get
            {
                string msg = null;
                rxValidate = new Regex(@"\d+", RegexOptions.Singleline);
                switch (property)
                {
                    case "ClassFee":
                        break;
                    case "ClassMonthFee":
                        break;
                    case "Amount":
                        break;
                    case "Reason":
                        break;
                    case "PayAmount":
                        break;
                    case "RepayFee":
                        break;
                    case "ClassFeeRepay":
                        break;
                    case "RepayReason":
                        break;
                    default:
                        throw new ArgumentException(
                            Resources.ValidationDefaultException_Error + property);
                }
                return msg;
            }
        }

        #endregion // IDataErrorInfo Members
    }
    
}
